package org.example.experiment;

import java.util.function.Predicate;

public class PredicateExperiment {
    public static void main(String[] args) {
        Predicate<Integer> isEven = n -> n % 2 == 0;
        Predicate<Integer> isPositive = n -> n > 0;

        Predicate<Integer> isEvenAndPositive = isEven.and(isPositive);

        System.out.println(isEvenAndPositive.test(4));  // 输出: true
        System.out.println(isEvenAndPositive.test(-4)); // 输出: false
        System.out.println(isEvenAndPositive.test(3));  // 输出: false
    }
}
